<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>再见Vue</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    {{msg}}
    <button v-on:click="clickHandler">修改数据</button>
    <button @click="destoryHandler">销毁</button>
  </div>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        msg: 'hello vue'
      },
      methods: {
        clickHandler() {
          this.msg = '你好 vue'
        },
        destoryHandler() {
          this.$destroy();
        }
      },
      // 初始化构建阶段
      beforeCreate() {
        console.log('before create');
      },
      created() {
        console.log('created');

        setTimeout(() => {
          this.clickHandler()
        }, 3000)
      },
      // 挂载阶段
      beforeMount() {
        console.log('before mount');
      },
      mounted() {
        console.log('mounted');
      },
      // 更新阶段
      beforeUpdate() {
        console.log('before update');
      },
      updated() {
        console.log('updated');
      },
      // 销毁阶段
      beforeDestroy() {
        console.log('before destroy');
      },
      destroyed() {
        console.log('destroyed');
      }
    })
  </script>
</body>

</html>